import { Bar } from '@ant-design/charts';
import React from 'react';
import { useRequest } from '@umijs/hooks';
import { getyjStatistic } from '@/services/zhirong/dataIntegration';
import { useState } from 'react';

const EnterpriseBar = () => {
  const [bar, setBar] = useState();
  const { loading: loadingBar } = useRequest(getyjStatistic, {
    onSuccess: (res) => {
      setBar(res.data);
    },
  });
  const config = {
    data: bar,
    xField: 'value',
    yField: 'type',
    barWidthRatio: 0.6,
    color: '#722ED1',
    meta: { type: '预警词', value: '数量' },
    xAxis: false,
  };
  return bar ? <Bar {...config} style={{ height: '80%' }} loading={loadingBar} /> : null;
};

export default EnterpriseBar;
